#ifndef __func_H__
#define __func_H__

#define _GNU_SOURCE

#include "client.h"

#define BUFFSIZE 1024
#define CONNSMAX 1024                                                       
#define LSIZE 1024                                                          

typedef enum CMD{
    CMD_TYPE_OTHERS = -1,
    CMD_TYPE_EXIT,
    CMD_TYPE_CD,
    CMD_TYPE_MV,
    CMD_TYPE_CP,
    CMD_TYPE_LS,
    CMD_TYPE_LL,
    CMD_TYPE_PWD,
    CMD_TYPE_PUTS,
    CMD_TYPE_GETS,
    CMD_TYPE_RM,
    CMD_TYPE_MKDIR
}cmdType;

//统一传参接口
typedef struct{
    int argLen;        //参数实际长度
    char arg[128];     //存放参数数组
}argument_t;

typedef struct{
   cmdType cmd;        //指令
   int argSize;        //参数个数
   argument_t args[2]; //指令后接参数的数组 具体参照上述结构体
}cmd_t;

//火车
typedef struct train{
    int length;
    char buff[BUFFSIZE];
}train_t;

//用户登录
void userLogin(int clientfd);

//拆分指令
cmd_t *analyzeCmd(char *cmd, size_t cmdsize);

int clientTcpInit(char* IP, int port);
void handleOrder(int clientfd);
void handlePuts(int clientfd, char* filename);
void handleGets(int clientfd);
int cd_client(int clientfd);
int mv_client(int clientfd); 
int cp_client(int clientfd);
int rm_client(int clientfd);
int pwd_client(int clientfd);
int getsfileplus_client(int peerfd,const char* pthname);
void regisAndlogin_client(int clientfd); 

#endif
